#special effects
#like gore


import pygame
import os

import data
import character
import animation
import random

def prepare():
    global goreimation
    goreimation = animation.Animation(os.path.join("gore","standard"))

class Gore(character.Character):
    def __init__(self, anim, pos, vel=(0,0), state=character.Falling(), coord_scale=None):
        global goreimage    
        if anim is not os.path.join("gore","standard"): #chetah
            character.Character.__init__(self, anim, pos, coord_scale, vel, state)
        else:
            character.Character.__init__(self, goreimation, pos, coord_scale, vel, state)
        self.starttime = pygame.time.get_ticks()
        self.image.set_alpha(150)
        
    def update(self, camera, curr_level):
        if pygame.time.get_ticks() - self.starttime > 3000: #delete after 3s
            self.kill()
        character.Character.update(self, camera, curr_level)
        
    
def gore_splash(pos, many = 10):
    i = 0
    gore_group = pygame.sprite.Group()
    while i < many:
        vel = random.randint(-8,8), random.randint(-10,-2)
        
        agore = Gore(os.path.join("gore", "standard"), pos, vel, None)
        agore.accelerate(vel)
        gore_group.add(agore)
        i += 1
        
    return gore_group
